from pyspark import SparkConf,SparkContext

conf = SparkConf().setMaster("local").setAppName("RDDDemo")
sc = SparkContext(conf=conf)



lines  = sc.textFile("file:///home/hadoop/MyTmp/sparkwordcount.txt")

wordCount = lines.flatMap(lambda line :line.split(" ")).map(lambda word:(word,1)).reduceByKey(lambda a,b:a+b)
print(wordCount.collect())
